﻿package com.javaPattern.Observer;

import java.util.*;

class Children implements Subject {
	static private ArrayList<Observer> obs;// 一个存储观察者的序列
	static private String state;
	static {
		obs = new ArrayList<Observer>();
	}

	public void attach(Observer o) {
		obs.add(o);
	}

	public void detach(Observer o) {
		obs.remove(o);
	}

	public void setState(String str) {
		state = str;
	}

	public String getState() {
		return state;
	}

	public void notifyObs() {
		for (Observer o : obs) {
			o.update(this);
		}
	}
}